<?php
import("com.dudulook.lib.ui.Control");
/**
 *
 */
class DataGrid extends Control
{
	public function __construct($data = null)
	{
		parent::__construct($data);
	}

	private function getHeader()
	{
		$str = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		$str .= "<tr>";
		foreach($this->data['header'] as $v)
		{
			$str .= "<td>".$v."</td>";
		}
		$str .= "</tr>";

		return $str;
	}

	private function getRows()
	{
		$str = "";

		foreach($this->data['data'] as $v)
		{
			$str .= "<tr>";
			foreach($v as $kk => $vv)
			{
				$str .= "<td>".$vv."</td>";
			}
			$str .= "</tr>";
		}

		return $str;
	}

	public function getFooter()
	{
		return "</table>";
	}

	public function render()
	{
		return $this->getHeader() . $this->getRows() . $this->getFooter();
	}
}
?>